import Vue from 'vue';
import Router from 'vue-router';
// eslint-disable-next-line no-unused-vars
import { constantRouterMap } from '@/config/router.config.js';

try {
  const originalPush = Router.prototype.push;
  Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
  };
} catch (e) {
}

const routerMerge = constantRouterMap;

Vue.use(Router);

export default new Router({
  mode: process.env.VUE_APP_ENV == 'pre' ? '' : '',
  base: `${process.env.VUE_APP_ROUTER_BASE_URL}`,
  scrollBehavior: () => ({ y: 0 }),
  routes: routerMerge
});
